using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using SSOF.Client.Silverlight.TempObjects;

namespace SSOF.Client.Silverlight
{
    public partial class Home : Page
    {
        DemoContext ctx;
        HomeQuestion currentSelectedQuestion;

        public Home()
        {
            InitializeComponent();
            ctx = DemoData.CreateData();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            dgQuestionList.ItemsSource = ctx.HomeQuestions.Take(8);                
        }

        private void dgQuestionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid grid = sender as DataGrid;
            if (grid.SelectedItem != null)
            {
                currentSelectedQuestion = grid.SelectedItem as HomeQuestion;
            }
            else
            {
                grid.SelectedItem = currentSelectedQuestion;
            }

            //questionDetail.Visibility = System.Windows.Visibility.Visible;


        }

    }
}
